/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: javaseapp - Switch1
 * <p>Powered by webrx On 2021-07-29 17:20:48
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Switch5 {
    public static void main(String[] args) {
        int y = 2021;
        int m = 11;

        //java12 switch表达式 -> 3;
        int days = switch (m) {
            case 2 -> {
                System.out.println("22222");
                yield (y % 400 == 0 || y % 4 == 0 && y % 100 != 0 ? 29 : 28);
            }
            case 4, 6, 9, 11 -> 30;
            default -> 31;
        };
        System.out.printf("%d年%d月有%d天", y, m, days);
        System.out.println("-------------------------------------");
        switch (m) {
            case 2 -> {
                System.out.println(y % 400 == 0 || y % 4 == 0 && y % 100 != 0 ? 29 : 28);
                System.out.println(y % 400 == 0 || y % 4 == 0 && y % 100 != 0 ? 29 : 28);
                System.out.println(y % 400 == 0 || y % 4 == 0 && y % 100 != 0 ? 29 : 28);
            }
            case 4, 6, 9, 11 -> {
                System.out.println(30);
            }
            default -> System.out.println(31);
        }
    }
}
